using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Base;
namespace Input
{
    public class InputController : IInputControllerService
    {
        private Dictionary<Actions, Keys> keyMappings = new Dictionary<Actions, Keys>();

        public Dictionary<Actions, Keys> KeyMappings
        {
            get { return keyMappings; }
            set { keyMappings = value; }
        }

        public InputController()
        {
            keyMappings.Add(Actions.Left, Keys.A);
            keyMappings.Add(Actions.Right, Keys.D);
            keyMappings.Add(Actions.Up, Keys.W);
            keyMappings.Add(Actions.Down, Keys.S);
            keyMappings.Add(Actions.Escape, Keys.Escape);
            keyMappings.Add(Actions.Help, Keys.F1);            
        }

        public bool Left
        {
            get
            {
                KeyboardState keystate = Keyboard.GetState();
                return keystate.IsKeyDown(keyMappings[Actions.Left]);
            }
        }

        public bool Right
        {
            get
            {
                KeyboardState keystate = Keyboard.GetState();
                return keystate.IsKeyDown(keyMappings[Actions.Right]);
            }
        }

        public bool Up
        {
            get
            {
                KeyboardState keystate = Keyboard.GetState();
                return keystate.IsKeyDown(keyMappings[Actions.Up]);
            }
        }

        public bool Down
        {
            get
            {
                KeyboardState keystate = Keyboard.GetState();
                return keystate.IsKeyDown(keyMappings[Actions.Down]);
            }
        }

        public bool Escape
        {
            get
            {
                KeyboardState keystate = Keyboard.GetState();
                return keystate.IsKeyDown(keyMappings[Actions.Escape]);
            }
        }

        public bool Help
        {
            get
            {
                KeyboardState keystate = Keyboard.GetState();
                return keystate.IsKeyDown(keyMappings[Actions.Help]);
            }
        }
    }
}
